package com.fa7.android.example.listafacil;

import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;

public class SplashActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.splash_layout);
		
		ImageView imageView = (ImageView)findViewById(R.id.splash_image);
		
		AssetManager assetManager = getAssets();
		
		try {
			InputStream istr = assetManager.open("app_splash.png");
			Bitmap bitmap = BitmapFactory.decodeStream(istr);
			
			imageView.setImageBitmap(bitmap);
		}
		catch (IOException e) {
			e.printStackTrace();
		}

		getActionBar().hide();
		
		Handler handler = new Handler();		
		handler.postDelayed(new SplashHandler(), 2000);
	}
	
	class SplashHandler implements Runnable {
		public void run() {
			Intent it = new Intent(getApplicationContext(), MainActivity.class);
			startActivity(it);
			SplashActivity.this.finish();
		}
	}

}